/**************************************
*****LAST UPDATED: NOVEMBER 13, 6:21 PM
 * ALL WORKING ALL TESTED
 **************************************/
#include <stdlib.h>
#include <stdio.h>

static int tracker=0; //tracker counter

struct link {
   int value;
   struct link *next;
};

typedef struct link ring;

ring *RING_IN = NULL, *RING_OUT, *temp;


void rb_insert(int x)
{
	RING_IN = (ring *)malloc(sizeof(ring));
	RING_IN->value = x;
	if(tracker==0)
		RING_OUT = RING_IN;
	RING_IN = RING_IN->next;
	tracker++;
}

int rb_fetch()
{
	int val;
	if(tracker<=0)
	{
		//ERROR RING BUFFER EMPTY
	}
	else
	{
		val = RING_OUT->value;
		RING_OUT = RING_OUT->next;
		tracker--;
		return val;
	}
}